<?php

/**
 * ShippingApi
 * PHP version 8.3.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * Amazon Shipping API.
 *
 * The Amazon Shipping API is designed to support outbound shipping use cases both for orders originating on Amazon-owned marketplaces as well as external channels/marketplaces. With these APIs, you can request shipping rates, create shipments, cancel shipments, and track shipments.
 *
 * The version of the OpenAPI document: v2
 * Contact: swa-api-core@amazon.com
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.9.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace SpApi\Api\shipping\v2;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use SpApi\ApiException;
use SpApi\AuthAndAuth\RestrictedDataTokenSigner;
use SpApi\Configuration;
use SpApi\HeaderSelector;
use SpApi\Model\shipping\v2\CancelShipmentResponse;
use SpApi\Model\shipping\v2\CreateClaimRequest;
use SpApi\Model\shipping\v2\CreateClaimResponse;
use SpApi\Model\shipping\v2\DirectPurchaseRequest;
use SpApi\Model\shipping\v2\DirectPurchaseResponse;
use SpApi\Model\shipping\v2\GenerateCollectionFormRequest;
use SpApi\Model\shipping\v2\GenerateCollectionFormResponse;
use SpApi\Model\shipping\v2\GetAccessPointsResponse;
use SpApi\Model\shipping\v2\GetAdditionalInputsResponse;
use SpApi\Model\shipping\v2\GetCarrierAccountFormInputsResponse;
use SpApi\Model\shipping\v2\GetCarrierAccountsRequest;
use SpApi\Model\shipping\v2\GetCarrierAccountsResponse;
use SpApi\Model\shipping\v2\GetCollectionFormHistoryRequest;
use SpApi\Model\shipping\v2\GetCollectionFormHistoryResponse;
use SpApi\Model\shipping\v2\GetCollectionFormResponse;
use SpApi\Model\shipping\v2\GetRatesRequest;
use SpApi\Model\shipping\v2\GetRatesResponse;
use SpApi\Model\shipping\v2\GetShipmentDocumentsResponse;
use SpApi\Model\shipping\v2\GetTrackingResponse;
use SpApi\Model\shipping\v2\GetUnmanifestedShipmentsRequest;
use SpApi\Model\shipping\v2\GetUnmanifestedShipmentsResponse;
use SpApi\Model\shipping\v2\LinkCarrierAccountRequest;
use SpApi\Model\shipping\v2\LinkCarrierAccountResponse;
use SpApi\Model\shipping\v2\OneClickShipmentRequest;
use SpApi\Model\shipping\v2\OneClickShipmentResponse;
use SpApi\Model\shipping\v2\PurchaseShipmentRequest;
use SpApi\Model\shipping\v2\PurchaseShipmentResponse;
use SpApi\Model\shipping\v2\SubmitNdrFeedbackRequest;
use SpApi\Model\shipping\v2\UnlinkCarrierAccountRequest;
use SpApi\Model\shipping\v2\UnlinkCarrierAccountResponse;
use SpApi\ObjectSerializer;
use Symfony\Component\RateLimiter\LimiterInterface;
use Symfony\Component\RateLimiter\RateLimiterFactory;
use Symfony\Component\RateLimiter\Storage\InMemoryStorage;

/**
 * ShippingApi Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */
class ShippingApi
{
    public ?LimiterInterface $cancelShipmentRateLimiter;
    public ?LimiterInterface $createClaimRateLimiter;
    public ?LimiterInterface $directPurchaseShipmentRateLimiter;
    public ?LimiterInterface $generateCollectionFormRateLimiter;
    public ?LimiterInterface $getAccessPointsRateLimiter;
    public ?LimiterInterface $getAdditionalInputsRateLimiter;
    public ?LimiterInterface $getCarrierAccountFormInputsRateLimiter;
    public ?LimiterInterface $getCarrierAccountsRateLimiter;
    public ?LimiterInterface $getCollectionFormRateLimiter;
    public ?LimiterInterface $getCollectionFormHistoryRateLimiter;
    public ?LimiterInterface $getRatesRateLimiter;
    public ?LimiterInterface $getShipmentDocumentsRateLimiter;
    public ?LimiterInterface $getTrackingRateLimiter;
    public ?LimiterInterface $getUnmanifestedShipmentsRateLimiter;
    public ?LimiterInterface $linkCarrierAccountRateLimiter;
    public ?LimiterInterface $linkCarrierAccount_0RateLimiter;
    public ?LimiterInterface $oneClickShipmentRateLimiter;
    public ?LimiterInterface $purchaseShipmentRateLimiter;
    public ?LimiterInterface $submitNdrFeedbackRateLimiter;
    public ?LimiterInterface $unlinkCarrierAccountRateLimiter;
    protected ClientInterface $client;

    protected Configuration $config;

    protected HeaderSelector $headerSelector;

    /**
     * @var int Host index
     */
    protected int $hostIndex;

    private bool $rateLimiterEnabled;
    private InMemoryStorage $rateLimitStorage;

    /**
     * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
     */
    public function __construct(
        Configuration $config,
        ?ClientInterface $client = null,
        ?bool $rateLimiterEnabled = true,
        ?HeaderSelector $selector = null,
        int $hostIndex = 0
    ) {
        $this->config = $config;
        $this->rateLimiterEnabled = $rateLimiterEnabled;

        if ($rateLimiterEnabled) {
            $this->rateLimitStorage = new InMemoryStorage();

            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-cancelShipment'), $this->rateLimitStorage);
            $this->cancelShipmentRateLimiter = $factory->create('ShippingApi-cancelShipment');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-createClaim'), $this->rateLimitStorage);
            $this->createClaimRateLimiter = $factory->create('ShippingApi-createClaim');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-directPurchaseShipment'), $this->rateLimitStorage);
            $this->directPurchaseShipmentRateLimiter = $factory->create('ShippingApi-directPurchaseShipment');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-generateCollectionForm'), $this->rateLimitStorage);
            $this->generateCollectionFormRateLimiter = $factory->create('ShippingApi-generateCollectionForm');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getAccessPoints'), $this->rateLimitStorage);
            $this->getAccessPointsRateLimiter = $factory->create('ShippingApi-getAccessPoints');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getAdditionalInputs'), $this->rateLimitStorage);
            $this->getAdditionalInputsRateLimiter = $factory->create('ShippingApi-getAdditionalInputs');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getCarrierAccountFormInputs'), $this->rateLimitStorage);
            $this->getCarrierAccountFormInputsRateLimiter = $factory->create('ShippingApi-getCarrierAccountFormInputs');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getCarrierAccounts'), $this->rateLimitStorage);
            $this->getCarrierAccountsRateLimiter = $factory->create('ShippingApi-getCarrierAccounts');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getCollectionForm'), $this->rateLimitStorage);
            $this->getCollectionFormRateLimiter = $factory->create('ShippingApi-getCollectionForm');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getCollectionFormHistory'), $this->rateLimitStorage);
            $this->getCollectionFormHistoryRateLimiter = $factory->create('ShippingApi-getCollectionFormHistory');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getRates'), $this->rateLimitStorage);
            $this->getRatesRateLimiter = $factory->create('ShippingApi-getRates');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getShipmentDocuments'), $this->rateLimitStorage);
            $this->getShipmentDocumentsRateLimiter = $factory->create('ShippingApi-getShipmentDocuments');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getTracking'), $this->rateLimitStorage);
            $this->getTrackingRateLimiter = $factory->create('ShippingApi-getTracking');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-getUnmanifestedShipments'), $this->rateLimitStorage);
            $this->getUnmanifestedShipmentsRateLimiter = $factory->create('ShippingApi-getUnmanifestedShipments');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-linkCarrierAccount'), $this->rateLimitStorage);
            $this->linkCarrierAccountRateLimiter = $factory->create('ShippingApi-linkCarrierAccount');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-linkCarrierAccount_0'), $this->rateLimitStorage);
            $this->linkCarrierAccount_0RateLimiter = $factory->create('ShippingApi-linkCarrierAccount_0');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-oneClickShipment'), $this->rateLimitStorage);
            $this->oneClickShipmentRateLimiter = $factory->create('ShippingApi-oneClickShipment');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-purchaseShipment'), $this->rateLimitStorage);
            $this->purchaseShipmentRateLimiter = $factory->create('ShippingApi-purchaseShipment');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-submitNdrFeedback'), $this->rateLimitStorage);
            $this->submitNdrFeedbackRateLimiter = $factory->create('ShippingApi-submitNdrFeedback');
            $factory = new RateLimiterFactory(Configuration::getRateLimitOptions('ShippingApi-unlinkCarrierAccount'), $this->rateLimitStorage);
            $this->unlinkCarrierAccountRateLimiter = $factory->create('ShippingApi-unlinkCarrierAccount');
        }

        $this->client = $client ?: new Client();
        $this->headerSelector = $selector ?: new HeaderSelector();
        $this->hostIndex = $hostIndex;
    }

    /**
     * Set the host index.
     *
     * @param int $hostIndex Host index (required)
     */
    public function setHostIndex(int $hostIndex): void
    {
        $this->hostIndex = $hostIndex;
    }

    /**
     * Get the host index.
     *
     * @return int Host index
     */
    public function getHostIndex(): int
    {
        return $this->hostIndex;
    }

    public function getConfig(): Configuration
    {
        return $this->config;
    }

    /**
     * Operation cancelShipment.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function cancelShipment(
        string $shipment_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): CancelShipmentResponse {
        list($response) = $this->cancelShipmentWithHttpInfo($shipment_id, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation cancelShipmentWithHttpInfo.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\CancelShipmentResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function cancelShipmentWithHttpInfo(
        string $shipment_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->cancelShipmentRequest($shipment_id, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-cancelShipment');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->cancelShipmentRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\CancelShipmentResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\CancelShipmentResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\CancelShipmentResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation cancelShipmentAsync.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function cancelShipmentAsync(
        string $shipment_id,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->cancelShipmentAsyncWithHttpInfo($shipment_id, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation cancelShipmentAsyncWithHttpInfo.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function cancelShipmentAsyncWithHttpInfo(
        string $shipment_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\CancelShipmentResponse';
        $request = $this->cancelShipmentRequest($shipment_id, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-cancelShipment');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->cancelShipmentRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'cancelShipment'.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function cancelShipmentRequest(
        string $shipment_id,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'shipment_id' is set
        if (null === $shipment_id || (is_array($shipment_id) && 0 === count($shipment_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $shipment_id when calling cancelShipment'
            );
        }

        $resourcePath = '/shipping/v2/shipments/{shipmentId}/cancel';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        // path params
        if (null !== $shipment_id) {
            $resourcePath = str_replace(
                '{shipmentId}',
                ObjectSerializer::toPathValue($shipment_id),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'PUT',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation createClaim.
     *
     * @param CreateClaimRequest $body
     *                                                        Request body for the createClaim operation (required)
     * @param null|string        $x_amzn_shipping_business_id
     *                                                        Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string        $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function createClaim(
        CreateClaimRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): CreateClaimResponse {
        list($response) = $this->createClaimWithHttpInfo($body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation createClaimWithHttpInfo.
     *
     * @param CreateClaimRequest $body
     *                                                        Request body for the createClaim operation (required)
     * @param null|string        $x_amzn_shipping_business_id
     *                                                        Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string        $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\CreateClaimResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function createClaimWithHttpInfo(
        CreateClaimRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->createClaimRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-createClaim');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->createClaimRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\CreateClaimResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\CreateClaimResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\CreateClaimResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation createClaimAsync.
     *
     * @param CreateClaimRequest $body
     *                                                        Request body for the createClaim operation (required)
     * @param null|string        $x_amzn_shipping_business_id
     *                                                        Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function createClaimAsync(
        CreateClaimRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->createClaimAsyncWithHttpInfo($body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation createClaimAsyncWithHttpInfo.
     *
     * @param CreateClaimRequest $body
     *                                                        Request body for the createClaim operation (required)
     * @param null|string        $x_amzn_shipping_business_id
     *                                                        Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function createClaimAsyncWithHttpInfo(
        CreateClaimRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\CreateClaimResponse';
        $request = $this->createClaimRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-createClaim');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->createClaimRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'createClaim'.
     *
     * @param CreateClaimRequest $body
     *                                                        Request body for the createClaim operation (required)
     * @param null|string        $x_amzn_shipping_business_id
     *                                                        Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function createClaimRequest(
        CreateClaimRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling createClaim'
            );
        }

        $resourcePath = '/shipping/v2/claims';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation directPurchaseShipment.
     *
     * @param DirectPurchaseRequest $body
     *                                                           DirectPurchaseRequest body (required)
     * @param null|string           $x_amzn_idempotency_key
     *                                                           A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string           $locale
     *                                                           The IETF Language Tag. Note that this only supports the primary language subtag with one secondary language subtag (i.e. en-US, fr-CA). The secondary language subtag is almost always a regional designation. This does not support additional subtags beyond the primary and secondary language subtags. (optional)
     * @param null|string           $x_amzn_shipping_business_id
     *                                                           Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string           $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function directPurchaseShipment(
        DirectPurchaseRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $locale = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): DirectPurchaseResponse {
        list($response) = $this->directPurchaseShipmentWithHttpInfo($body, $x_amzn_idempotency_key, $locale, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation directPurchaseShipmentWithHttpInfo.
     *
     * @param DirectPurchaseRequest $body
     *                                                           DirectPurchaseRequest body (required)
     * @param null|string           $x_amzn_idempotency_key
     *                                                           A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string           $locale
     *                                                           The IETF Language Tag. Note that this only supports the primary language subtag with one secondary language subtag (i.e. en-US, fr-CA). The secondary language subtag is almost always a regional designation. This does not support additional subtags beyond the primary and secondary language subtags. (optional)
     * @param null|string           $x_amzn_shipping_business_id
     *                                                           Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string           $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\DirectPurchaseResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function directPurchaseShipmentWithHttpInfo(
        DirectPurchaseRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $locale = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->directPurchaseShipmentRequest($body, $x_amzn_idempotency_key, $locale, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-directPurchaseShipment');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->directPurchaseShipmentRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\DirectPurchaseResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\DirectPurchaseResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\DirectPurchaseResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation directPurchaseShipmentAsync.
     *
     * @param DirectPurchaseRequest $body
     *                                                           DirectPurchaseRequest body (required)
     * @param null|string           $x_amzn_idempotency_key
     *                                                           A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string           $locale
     *                                                           The IETF Language Tag. Note that this only supports the primary language subtag with one secondary language subtag (i.e. en-US, fr-CA). The secondary language subtag is almost always a regional designation. This does not support additional subtags beyond the primary and secondary language subtags. (optional)
     * @param null|string           $x_amzn_shipping_business_id
     *                                                           Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function directPurchaseShipmentAsync(
        DirectPurchaseRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $locale = null,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->directPurchaseShipmentAsyncWithHttpInfo($body, $x_amzn_idempotency_key, $locale, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation directPurchaseShipmentAsyncWithHttpInfo.
     *
     * @param DirectPurchaseRequest $body
     *                                                           DirectPurchaseRequest body (required)
     * @param null|string           $x_amzn_idempotency_key
     *                                                           A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string           $locale
     *                                                           The IETF Language Tag. Note that this only supports the primary language subtag with one secondary language subtag (i.e. en-US, fr-CA). The secondary language subtag is almost always a regional designation. This does not support additional subtags beyond the primary and secondary language subtags. (optional)
     * @param null|string           $x_amzn_shipping_business_id
     *                                                           Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function directPurchaseShipmentAsyncWithHttpInfo(
        DirectPurchaseRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $locale = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\DirectPurchaseResponse';
        $request = $this->directPurchaseShipmentRequest($body, $x_amzn_idempotency_key, $locale, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-directPurchaseShipment');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->directPurchaseShipmentRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'directPurchaseShipment'.
     *
     * @param DirectPurchaseRequest $body
     *                                                           DirectPurchaseRequest body (required)
     * @param null|string           $x_amzn_idempotency_key
     *                                                           A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string           $locale
     *                                                           The IETF Language Tag. Note that this only supports the primary language subtag with one secondary language subtag (i.e. en-US, fr-CA). The secondary language subtag is almost always a regional designation. This does not support additional subtags beyond the primary and secondary language subtags. (optional)
     * @param null|string           $x_amzn_shipping_business_id
     *                                                           Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function directPurchaseShipmentRequest(
        DirectPurchaseRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $locale = null,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling directPurchaseShipment'
            );
        }

        $resourcePath = '/shipping/v2/shipments/directPurchase';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_idempotency_key) {
            $headerParams['x-amzn-IdempotencyKey'] = ObjectSerializer::toHeaderValue($x_amzn_idempotency_key);
        }
        // header params
        if (null !== $locale) {
            $headerParams['locale'] = ObjectSerializer::toHeaderValue($locale);
        }
        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation generateCollectionForm.
     *
     * @param GenerateCollectionFormRequest $body
     *                                                                   GenerateCollectionFormRequest body (required)
     * @param null|string                   $x_amzn_idempotency_key
     *                                                                   A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string                   $x_amzn_shipping_business_id
     *                                                                   Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string                   $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function generateCollectionForm(
        GenerateCollectionFormRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GenerateCollectionFormResponse {
        list($response) = $this->generateCollectionFormWithHttpInfo($body, $x_amzn_idempotency_key, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation generateCollectionFormWithHttpInfo.
     *
     * @param GenerateCollectionFormRequest $body
     *                                                                   GenerateCollectionFormRequest body (required)
     * @param null|string                   $x_amzn_idempotency_key
     *                                                                   A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string                   $x_amzn_shipping_business_id
     *                                                                   Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string                   $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GenerateCollectionFormResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function generateCollectionFormWithHttpInfo(
        GenerateCollectionFormRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->generateCollectionFormRequest($body, $x_amzn_idempotency_key, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-generateCollectionForm');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->generateCollectionFormRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GenerateCollectionFormResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GenerateCollectionFormResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GenerateCollectionFormResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation generateCollectionFormAsync.
     *
     * @param GenerateCollectionFormRequest $body
     *                                                                   GenerateCollectionFormRequest body (required)
     * @param null|string                   $x_amzn_idempotency_key
     *                                                                   A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string                   $x_amzn_shipping_business_id
     *                                                                   Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function generateCollectionFormAsync(
        GenerateCollectionFormRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->generateCollectionFormAsyncWithHttpInfo($body, $x_amzn_idempotency_key, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation generateCollectionFormAsyncWithHttpInfo.
     *
     * @param GenerateCollectionFormRequest $body
     *                                                                   GenerateCollectionFormRequest body (required)
     * @param null|string                   $x_amzn_idempotency_key
     *                                                                   A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string                   $x_amzn_shipping_business_id
     *                                                                   Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function generateCollectionFormAsyncWithHttpInfo(
        GenerateCollectionFormRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GenerateCollectionFormResponse';
        $request = $this->generateCollectionFormRequest($body, $x_amzn_idempotency_key, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-generateCollectionForm');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->generateCollectionFormRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'generateCollectionForm'.
     *
     * @param GenerateCollectionFormRequest $body
     *                                                                   GenerateCollectionFormRequest body (required)
     * @param null|string                   $x_amzn_idempotency_key
     *                                                                   A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string                   $x_amzn_shipping_business_id
     *                                                                   Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function generateCollectionFormRequest(
        GenerateCollectionFormRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling generateCollectionForm'
            );
        }

        $resourcePath = '/shipping/v2/collectionForms';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_idempotency_key) {
            $headerParams['x-amzn-IdempotencyKey'] = ObjectSerializer::toHeaderValue($x_amzn_idempotency_key);
        }
        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getAccessPoints.
     *
     * @param string[]    $access_point_types
     *                                                 Access point types (required)
     * @param string      $country_code
     *                                                 Country code for access point (required)
     * @param string      $postal_code
     *                                                 postal code for access point (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getAccessPoints(
        array $access_point_types,
        string $country_code,
        string $postal_code,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetAccessPointsResponse {
        list($response) = $this->getAccessPointsWithHttpInfo($access_point_types, $country_code, $postal_code, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getAccessPointsWithHttpInfo.
     *
     * @param string[]    $access_point_types
     *                                                 Access point types (required)
     * @param string      $country_code
     *                                                 Country code for access point (required)
     * @param string      $postal_code
     *                                                 postal code for access point (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetAccessPointsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getAccessPointsWithHttpInfo(
        array $access_point_types,
        string $country_code,
        string $postal_code,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getAccessPointsRequest($access_point_types, $country_code, $postal_code, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getAccessPoints');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getAccessPointsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetAccessPointsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetAccessPointsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetAccessPointsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getAccessPointsAsync.
     *
     * @param string[]    $access_point_types
     *                                                 Access point types (required)
     * @param string      $country_code
     *                                                 Country code for access point (required)
     * @param string      $postal_code
     *                                                 postal code for access point (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getAccessPointsAsync(
        array $access_point_types,
        string $country_code,
        string $postal_code,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getAccessPointsAsyncWithHttpInfo($access_point_types, $country_code, $postal_code, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getAccessPointsAsyncWithHttpInfo.
     *
     * @param string[]    $access_point_types
     *                                                 Access point types (required)
     * @param string      $country_code
     *                                                 Country code for access point (required)
     * @param string      $postal_code
     *                                                 postal code for access point (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getAccessPointsAsyncWithHttpInfo(
        array $access_point_types,
        string $country_code,
        string $postal_code,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetAccessPointsResponse';
        $request = $this->getAccessPointsRequest($access_point_types, $country_code, $postal_code, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getAccessPoints');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getAccessPointsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getAccessPoints'.
     *
     * @param string[]    $access_point_types
     *                                                 Access point types (required)
     * @param string      $country_code
     *                                                 Country code for access point (required)
     * @param string      $postal_code
     *                                                 postal code for access point (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getAccessPointsRequest(
        array $access_point_types,
        string $country_code,
        string $postal_code,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'access_point_types' is set
        if (null === $access_point_types || (is_array($access_point_types) && 0 === count($access_point_types))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $access_point_types when calling getAccessPoints'
            );
        }
        // verify the required parameter 'country_code' is set
        if (null === $country_code || (is_array($country_code) && 0 === count($country_code))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $country_code when calling getAccessPoints'
            );
        }
        // verify the required parameter 'postal_code' is set
        if (null === $postal_code || (is_array($postal_code) && 0 === count($postal_code))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $postal_code when calling getAccessPoints'
            );
        }

        $resourcePath = '/shipping/v2/accessPoints';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $access_point_types,
            'accessPointTypes', // param base name
            'array', // openApiType
            'form', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $country_code,
            'countryCode', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $postal_code,
            'postalCode', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getAdditionalInputs.
     *
     * @param string      $request_token
     *                                                 The request token returned in the response to the getRates operation. (required)
     * @param string      $rate_id
     *                                                 The rate identifier for the shipping offering (rate) returned in the response to the getRates operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getAdditionalInputs(
        string $request_token,
        string $rate_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetAdditionalInputsResponse {
        list($response) = $this->getAdditionalInputsWithHttpInfo($request_token, $rate_id, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getAdditionalInputsWithHttpInfo.
     *
     * @param string      $request_token
     *                                                 The request token returned in the response to the getRates operation. (required)
     * @param string      $rate_id
     *                                                 The rate identifier for the shipping offering (rate) returned in the response to the getRates operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetAdditionalInputsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getAdditionalInputsWithHttpInfo(
        string $request_token,
        string $rate_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getAdditionalInputsRequest($request_token, $rate_id, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getAdditionalInputs');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getAdditionalInputsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetAdditionalInputsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetAdditionalInputsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetAdditionalInputsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getAdditionalInputsAsync.
     *
     * @param string      $request_token
     *                                                 The request token returned in the response to the getRates operation. (required)
     * @param string      $rate_id
     *                                                 The rate identifier for the shipping offering (rate) returned in the response to the getRates operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getAdditionalInputsAsync(
        string $request_token,
        string $rate_id,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getAdditionalInputsAsyncWithHttpInfo($request_token, $rate_id, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getAdditionalInputsAsyncWithHttpInfo.
     *
     * @param string      $request_token
     *                                                 The request token returned in the response to the getRates operation. (required)
     * @param string      $rate_id
     *                                                 The rate identifier for the shipping offering (rate) returned in the response to the getRates operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getAdditionalInputsAsyncWithHttpInfo(
        string $request_token,
        string $rate_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetAdditionalInputsResponse';
        $request = $this->getAdditionalInputsRequest($request_token, $rate_id, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getAdditionalInputs');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getAdditionalInputsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getAdditionalInputs'.
     *
     * @param string      $request_token
     *                                                 The request token returned in the response to the getRates operation. (required)
     * @param string      $rate_id
     *                                                 The rate identifier for the shipping offering (rate) returned in the response to the getRates operation. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getAdditionalInputsRequest(
        string $request_token,
        string $rate_id,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'request_token' is set
        if (null === $request_token || (is_array($request_token) && 0 === count($request_token))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $request_token when calling getAdditionalInputs'
            );
        }
        // verify the required parameter 'rate_id' is set
        if (null === $rate_id || (is_array($rate_id) && 0 === count($rate_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $rate_id when calling getAdditionalInputs'
            );
        }

        $resourcePath = '/shipping/v2/shipments/additionalInputs/schema';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $request_token,
            'requestToken', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $rate_id,
            'rateId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getCarrierAccountFormInputs.
     *
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountFormInputs(
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetCarrierAccountFormInputsResponse {
        list($response) = $this->getCarrierAccountFormInputsWithHttpInfo($x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getCarrierAccountFormInputsWithHttpInfo.
     *
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetCarrierAccountFormInputsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountFormInputsWithHttpInfo(
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getCarrierAccountFormInputsRequest($x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getCarrierAccountFormInputs');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getCarrierAccountFormInputsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetCarrierAccountFormInputsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetCarrierAccountFormInputsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetCarrierAccountFormInputsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getCarrierAccountFormInputsAsync.
     *
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountFormInputsAsync(
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getCarrierAccountFormInputsAsyncWithHttpInfo($x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getCarrierAccountFormInputsAsyncWithHttpInfo.
     *
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountFormInputsAsyncWithHttpInfo(
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetCarrierAccountFormInputsResponse';
        $request = $this->getCarrierAccountFormInputsRequest($x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getCarrierAccountFormInputs');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getCarrierAccountFormInputsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getCarrierAccountFormInputs'.
     *
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountFormInputsRequest(
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        $resourcePath = '/shipping/v2/carrierAccountFormInputs';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getCarrierAccounts.
     *
     * @param GetCarrierAccountsRequest $body
     *                                                               GetCarrierAccountsRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string               $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccounts(
        GetCarrierAccountsRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetCarrierAccountsResponse {
        list($response) = $this->getCarrierAccountsWithHttpInfo($body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getCarrierAccountsWithHttpInfo.
     *
     * @param GetCarrierAccountsRequest $body
     *                                                               GetCarrierAccountsRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string               $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetCarrierAccountsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountsWithHttpInfo(
        GetCarrierAccountsRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getCarrierAccountsRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getCarrierAccounts');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getCarrierAccountsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetCarrierAccountsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetCarrierAccountsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetCarrierAccountsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getCarrierAccountsAsync.
     *
     * @param GetCarrierAccountsRequest $body
     *                                                               GetCarrierAccountsRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountsAsync(
        GetCarrierAccountsRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getCarrierAccountsAsyncWithHttpInfo($body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getCarrierAccountsAsyncWithHttpInfo.
     *
     * @param GetCarrierAccountsRequest $body
     *                                                               GetCarrierAccountsRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountsAsyncWithHttpInfo(
        GetCarrierAccountsRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetCarrierAccountsResponse';
        $request = $this->getCarrierAccountsRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getCarrierAccounts');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getCarrierAccountsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getCarrierAccounts'.
     *
     * @param GetCarrierAccountsRequest $body
     *                                                               GetCarrierAccountsRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCarrierAccountsRequest(
        GetCarrierAccountsRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling getCarrierAccounts'
            );
        }

        $resourcePath = '/shipping/v2/carrierAccounts';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'PUT',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getCollectionForm.
     *
     * @param string      $collection_form_id
     *                                                 collection form Id to reprint a collection. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getCollectionForm(
        string $collection_form_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetCollectionFormResponse {
        list($response) = $this->getCollectionFormWithHttpInfo($collection_form_id, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getCollectionFormWithHttpInfo.
     *
     * @param string      $collection_form_id
     *                                                 collection form Id to reprint a collection. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetCollectionFormResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormWithHttpInfo(
        string $collection_form_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getCollectionFormRequest($collection_form_id, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getCollectionForm');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getCollectionFormRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetCollectionFormResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetCollectionFormResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetCollectionFormResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getCollectionFormAsync.
     *
     * @param string      $collection_form_id
     *                                                 collection form Id to reprint a collection. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormAsync(
        string $collection_form_id,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getCollectionFormAsyncWithHttpInfo($collection_form_id, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getCollectionFormAsyncWithHttpInfo.
     *
     * @param string      $collection_form_id
     *                                                 collection form Id to reprint a collection. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormAsyncWithHttpInfo(
        string $collection_form_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetCollectionFormResponse';
        $request = $this->getCollectionFormRequest($collection_form_id, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getCollectionForm');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getCollectionFormRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getCollectionForm'.
     *
     * @param string      $collection_form_id
     *                                                 collection form Id to reprint a collection. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormRequest(
        string $collection_form_id,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'collection_form_id' is set
        if (null === $collection_form_id || (is_array($collection_form_id) && 0 === count($collection_form_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $collection_form_id when calling getCollectionForm'
            );
        }

        $resourcePath = '/shipping/v2/collectionForms/{collectionFormId}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        // path params
        if (null !== $collection_form_id) {
            $resourcePath = str_replace(
                '{collectionFormId}',
                ObjectSerializer::toPathValue($collection_form_id),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getCollectionFormHistory.
     *
     * @param GetCollectionFormHistoryRequest $body
     *                                                                     GetCollectionFormHistoryRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string                     $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormHistory(
        GetCollectionFormHistoryRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetCollectionFormHistoryResponse {
        list($response) = $this->getCollectionFormHistoryWithHttpInfo($body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getCollectionFormHistoryWithHttpInfo.
     *
     * @param GetCollectionFormHistoryRequest $body
     *                                                                     GetCollectionFormHistoryRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string                     $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetCollectionFormHistoryResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormHistoryWithHttpInfo(
        GetCollectionFormHistoryRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getCollectionFormHistoryRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getCollectionFormHistory');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getCollectionFormHistoryRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetCollectionFormHistoryResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetCollectionFormHistoryResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetCollectionFormHistoryResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getCollectionFormHistoryAsync.
     *
     * @param GetCollectionFormHistoryRequest $body
     *                                                                     GetCollectionFormHistoryRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormHistoryAsync(
        GetCollectionFormHistoryRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getCollectionFormHistoryAsyncWithHttpInfo($body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getCollectionFormHistoryAsyncWithHttpInfo.
     *
     * @param GetCollectionFormHistoryRequest $body
     *                                                                     GetCollectionFormHistoryRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormHistoryAsyncWithHttpInfo(
        GetCollectionFormHistoryRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetCollectionFormHistoryResponse';
        $request = $this->getCollectionFormHistoryRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getCollectionFormHistory');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getCollectionFormHistoryRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getCollectionFormHistory'.
     *
     * @param GetCollectionFormHistoryRequest $body
     *                                                                     GetCollectionFormHistoryRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getCollectionFormHistoryRequest(
        GetCollectionFormHistoryRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling getCollectionFormHistory'
            );
        }

        $resourcePath = '/shipping/v2/collectionForms/history';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'PUT',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getRates.
     *
     * @param GetRatesRequest $body
     *                                                     GetRatesRequest body (required)
     * @param null|string     $x_amzn_shipping_business_id
     *                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string     $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getRates(
        GetRatesRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetRatesResponse {
        list($response) = $this->getRatesWithHttpInfo($body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getRatesWithHttpInfo.
     *
     * @param GetRatesRequest $body
     *                                                     GetRatesRequest body (required)
     * @param null|string     $x_amzn_shipping_business_id
     *                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string     $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetRatesResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getRatesWithHttpInfo(
        GetRatesRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getRatesRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getRates');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getRatesRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetRatesResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetRatesResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetRatesResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getRatesAsync.
     *
     * @param GetRatesRequest $body
     *                                                     GetRatesRequest body (required)
     * @param null|string     $x_amzn_shipping_business_id
     *                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getRatesAsync(
        GetRatesRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getRatesAsyncWithHttpInfo($body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getRatesAsyncWithHttpInfo.
     *
     * @param GetRatesRequest $body
     *                                                     GetRatesRequest body (required)
     * @param null|string     $x_amzn_shipping_business_id
     *                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getRatesAsyncWithHttpInfo(
        GetRatesRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetRatesResponse';
        $request = $this->getRatesRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getRates');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getRatesRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getRates'.
     *
     * @param GetRatesRequest $body
     *                                                     GetRatesRequest body (required)
     * @param null|string     $x_amzn_shipping_business_id
     *                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getRatesRequest(
        GetRatesRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling getRates'
            );
        }

        $resourcePath = '/shipping/v2/shipments/rates';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getShipmentDocuments.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $package_client_reference_id
     *                                                 The package client reference identifier originally provided in the request body parameter for the getRates operation. (required)
     * @param null|string $format
     *                                                 The file format of the document. Must be one of the supported formats returned by the getRates operation. (optional)
     * @param null|float  $dpi
     *                                                 The resolution of the document (for example, 300 means 300 dots per inch). Must be one of the supported resolutions returned in the response to the getRates operation. (optional)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getShipmentDocuments(
        string $shipment_id,
        string $package_client_reference_id,
        ?string $format = null,
        ?float $dpi = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetShipmentDocumentsResponse {
        list($response) = $this->getShipmentDocumentsWithHttpInfo($shipment_id, $package_client_reference_id, $format, $dpi, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getShipmentDocumentsWithHttpInfo.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $package_client_reference_id
     *                                                 The package client reference identifier originally provided in the request body parameter for the getRates operation. (required)
     * @param null|string $format
     *                                                 The file format of the document. Must be one of the supported formats returned by the getRates operation. (optional)
     * @param null|float  $dpi
     *                                                 The resolution of the document (for example, 300 means 300 dots per inch). Must be one of the supported resolutions returned in the response to the getRates operation. (optional)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetShipmentDocumentsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getShipmentDocumentsWithHttpInfo(
        string $shipment_id,
        string $package_client_reference_id,
        ?string $format = null,
        ?float $dpi = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getShipmentDocumentsRequest($shipment_id, $package_client_reference_id, $format, $dpi, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getShipmentDocuments');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getShipmentDocumentsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetShipmentDocumentsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetShipmentDocumentsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetShipmentDocumentsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getShipmentDocumentsAsync.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $package_client_reference_id
     *                                                 The package client reference identifier originally provided in the request body parameter for the getRates operation. (required)
     * @param null|string $format
     *                                                 The file format of the document. Must be one of the supported formats returned by the getRates operation. (optional)
     * @param null|float  $dpi
     *                                                 The resolution of the document (for example, 300 means 300 dots per inch). Must be one of the supported resolutions returned in the response to the getRates operation. (optional)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getShipmentDocumentsAsync(
        string $shipment_id,
        string $package_client_reference_id,
        ?string $format = null,
        ?float $dpi = null,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getShipmentDocumentsAsyncWithHttpInfo($shipment_id, $package_client_reference_id, $format, $dpi, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getShipmentDocumentsAsyncWithHttpInfo.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $package_client_reference_id
     *                                                 The package client reference identifier originally provided in the request body parameter for the getRates operation. (required)
     * @param null|string $format
     *                                                 The file format of the document. Must be one of the supported formats returned by the getRates operation. (optional)
     * @param null|float  $dpi
     *                                                 The resolution of the document (for example, 300 means 300 dots per inch). Must be one of the supported resolutions returned in the response to the getRates operation. (optional)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getShipmentDocumentsAsyncWithHttpInfo(
        string $shipment_id,
        string $package_client_reference_id,
        ?string $format = null,
        ?float $dpi = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetShipmentDocumentsResponse';
        $request = $this->getShipmentDocumentsRequest($shipment_id, $package_client_reference_id, $format, $dpi, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getShipmentDocuments');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getShipmentDocumentsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getShipmentDocuments'.
     *
     * @param string      $shipment_id
     *                                                 The shipment identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $package_client_reference_id
     *                                                 The package client reference identifier originally provided in the request body parameter for the getRates operation. (required)
     * @param null|string $format
     *                                                 The file format of the document. Must be one of the supported formats returned by the getRates operation. (optional)
     * @param null|float  $dpi
     *                                                 The resolution of the document (for example, 300 means 300 dots per inch). Must be one of the supported resolutions returned in the response to the getRates operation. (optional)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getShipmentDocumentsRequest(
        string $shipment_id,
        string $package_client_reference_id,
        ?string $format = null,
        ?float $dpi = null,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'shipment_id' is set
        if (null === $shipment_id || (is_array($shipment_id) && 0 === count($shipment_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $shipment_id when calling getShipmentDocuments'
            );
        }
        // verify the required parameter 'package_client_reference_id' is set
        if (null === $package_client_reference_id || (is_array($package_client_reference_id) && 0 === count($package_client_reference_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $package_client_reference_id when calling getShipmentDocuments'
            );
        }

        $resourcePath = '/shipping/v2/shipments/{shipmentId}/documents';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $package_client_reference_id,
            'packageClientReferenceId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $format,
            'format', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $dpi,
            'dpi', // param base name
            'number', // openApiType
            '', // style
            false, // explode
            false, // required
            $this->config
        ) ?? []);

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        // path params
        if (null !== $shipment_id) {
            $resourcePath = str_replace(
                '{shipmentId}',
                ObjectSerializer::toPathValue($shipment_id),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getTracking.
     *
     * @param string      $tracking_id
     *                                                 A carrier-generated tracking identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $carrier_id
     *                                                 A carrier identifier originally returned by the getRates operation for the selected rate. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getTracking(
        string $tracking_id,
        string $carrier_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetTrackingResponse {
        list($response) = $this->getTrackingWithHttpInfo($tracking_id, $carrier_id, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getTrackingWithHttpInfo.
     *
     * @param string      $tracking_id
     *                                                 A carrier-generated tracking identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $carrier_id
     *                                                 A carrier identifier originally returned by the getRates operation for the selected rate. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetTrackingResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getTrackingWithHttpInfo(
        string $tracking_id,
        string $carrier_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getTrackingRequest($tracking_id, $carrier_id, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getTracking');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getTrackingRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetTrackingResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetTrackingResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetTrackingResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getTrackingAsync.
     *
     * @param string      $tracking_id
     *                                                 A carrier-generated tracking identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $carrier_id
     *                                                 A carrier identifier originally returned by the getRates operation for the selected rate. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getTrackingAsync(
        string $tracking_id,
        string $carrier_id,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getTrackingAsyncWithHttpInfo($tracking_id, $carrier_id, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getTrackingAsyncWithHttpInfo.
     *
     * @param string      $tracking_id
     *                                                 A carrier-generated tracking identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $carrier_id
     *                                                 A carrier identifier originally returned by the getRates operation for the selected rate. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getTrackingAsyncWithHttpInfo(
        string $tracking_id,
        string $carrier_id,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetTrackingResponse';
        $request = $this->getTrackingRequest($tracking_id, $carrier_id, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getTracking');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getTrackingRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getTracking'.
     *
     * @param string      $tracking_id
     *                                                 A carrier-generated tracking identifier originally returned by the purchaseShipment operation. (required)
     * @param string      $carrier_id
     *                                                 A carrier identifier originally returned by the getRates operation for the selected rate. (required)
     * @param null|string $x_amzn_shipping_business_id
     *                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getTrackingRequest(
        string $tracking_id,
        string $carrier_id,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'tracking_id' is set
        if (null === $tracking_id || (is_array($tracking_id) && 0 === count($tracking_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tracking_id when calling getTracking'
            );
        }
        // verify the required parameter 'carrier_id' is set
        if (null === $carrier_id || (is_array($carrier_id) && 0 === count($carrier_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $carrier_id when calling getTracking'
            );
        }

        $resourcePath = '/shipping/v2/tracking';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $tracking_id,
            'trackingId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $carrier_id,
            'carrierId', // param base name
            'string', // openApiType
            '', // style
            false, // explode
            true, // required
            $this->config
        ) ?? []);

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            '',
            $multipart
        );

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'GET',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getUnmanifestedShipments.
     *
     * @param GetUnmanifestedShipmentsRequest $body
     *                                                                     GetUmanifestedShipmentsRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string                     $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getUnmanifestedShipments(
        GetUnmanifestedShipmentsRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): GetUnmanifestedShipmentsResponse {
        list($response) = $this->getUnmanifestedShipmentsWithHttpInfo($body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation getUnmanifestedShipmentsWithHttpInfo.
     *
     * @param GetUnmanifestedShipmentsRequest $body
     *                                                                     GetUmanifestedShipmentsRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string                     $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\GetUnmanifestedShipmentsResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function getUnmanifestedShipmentsWithHttpInfo(
        GetUnmanifestedShipmentsRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->getUnmanifestedShipmentsRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getUnmanifestedShipments');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->getUnmanifestedShipmentsRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\GetUnmanifestedShipmentsResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\GetUnmanifestedShipmentsResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\GetUnmanifestedShipmentsResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation getUnmanifestedShipmentsAsync.
     *
     * @param GetUnmanifestedShipmentsRequest $body
     *                                                                     GetUmanifestedShipmentsRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getUnmanifestedShipmentsAsync(
        GetUnmanifestedShipmentsRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->getUnmanifestedShipmentsAsyncWithHttpInfo($body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation getUnmanifestedShipmentsAsyncWithHttpInfo.
     *
     * @param GetUnmanifestedShipmentsRequest $body
     *                                                                     GetUmanifestedShipmentsRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getUnmanifestedShipmentsAsyncWithHttpInfo(
        GetUnmanifestedShipmentsRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\GetUnmanifestedShipmentsResponse';
        $request = $this->getUnmanifestedShipmentsRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-getUnmanifestedShipments');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->getUnmanifestedShipmentsRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'getUnmanifestedShipments'.
     *
     * @param GetUnmanifestedShipmentsRequest $body
     *                                                                     GetUmanifestedShipmentsRequest body (required)
     * @param null|string                     $x_amzn_shipping_business_id
     *                                                                     Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function getUnmanifestedShipmentsRequest(
        GetUnmanifestedShipmentsRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling getUnmanifestedShipments'
            );
        }

        $resourcePath = '/shipping/v2/unmanifestedShipments';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'PUT',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation linkCarrierAccount.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string               $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccount(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): LinkCarrierAccountResponse {
        list($response) = $this->linkCarrierAccountWithHttpInfo($carrier_id, $body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation linkCarrierAccountWithHttpInfo.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string               $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\LinkCarrierAccountResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccountWithHttpInfo(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->linkCarrierAccountRequest($carrier_id, $body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-linkCarrierAccount');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->linkCarrierAccountRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\LinkCarrierAccountResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\LinkCarrierAccountResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\LinkCarrierAccountResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation linkCarrierAccountAsync.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccountAsync(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->linkCarrierAccountAsyncWithHttpInfo($carrier_id, $body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation linkCarrierAccountAsyncWithHttpInfo.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccountAsyncWithHttpInfo(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\LinkCarrierAccountResponse';
        $request = $this->linkCarrierAccountRequest($carrier_id, $body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-linkCarrierAccount');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->linkCarrierAccountRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'linkCarrierAccount'.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccountRequest(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'carrier_id' is set
        if (null === $carrier_id || (is_array($carrier_id) && 0 === count($carrier_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $carrier_id when calling linkCarrierAccount'
            );
        }
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling linkCarrierAccount'
            );
        }

        $resourcePath = '/shipping/v2/carrierAccounts/{carrierId}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        // path params
        if (null !== $carrier_id) {
            $resourcePath = str_replace(
                '{carrierId}',
                ObjectSerializer::toPathValue($carrier_id),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'PUT',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation linkCarrierAccount_0.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string               $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccount_0(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): LinkCarrierAccountResponse {
        list($response) = $this->linkCarrierAccount_0WithHttpInfo($carrier_id, $body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation linkCarrierAccount_0WithHttpInfo.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string               $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\LinkCarrierAccountResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccount_0WithHttpInfo(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->linkCarrierAccount_0Request($carrier_id, $body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-linkCarrierAccount_0');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->linkCarrierAccount_0RateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\LinkCarrierAccountResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\LinkCarrierAccountResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\LinkCarrierAccountResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation linkCarrierAccount_0Async.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccount_0Async(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->linkCarrierAccount_0AsyncWithHttpInfo($carrier_id, $body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation linkCarrierAccount_0AsyncWithHttpInfo.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccount_0AsyncWithHttpInfo(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\LinkCarrierAccountResponse';
        $request = $this->linkCarrierAccount_0Request($carrier_id, $body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-linkCarrierAccount_0');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->linkCarrierAccount_0RateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'linkCarrierAccount_0'.
     *
     * @param string                    $carrier_id
     *                                                               An identifier for the carrier with which the seller&#39;s account is being linked. (required)
     * @param LinkCarrierAccountRequest $body
     *                                                               LinkCarrierAccountRequest body (required)
     * @param null|string               $x_amzn_shipping_business_id
     *                                                               Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function linkCarrierAccount_0Request(
        string $carrier_id,
        LinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'carrier_id' is set
        if (null === $carrier_id || (is_array($carrier_id) && 0 === count($carrier_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $carrier_id when calling linkCarrierAccount_0'
            );
        }
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling linkCarrierAccount_0'
            );
        }

        $resourcePath = '/shipping/v2/carrierAccounts/{carrierId}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        // path params
        if (null !== $carrier_id) {
            $resourcePath = str_replace(
                '{carrierId}',
                ObjectSerializer::toPathValue($carrier_id),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation oneClickShipment.
     *
     * @param OneClickShipmentRequest $body
     *                                                             OneClickShipmentRequest body (required)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string             $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function oneClickShipment(
        OneClickShipmentRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): OneClickShipmentResponse {
        list($response) = $this->oneClickShipmentWithHttpInfo($body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation oneClickShipmentWithHttpInfo.
     *
     * @param OneClickShipmentRequest $body
     *                                                             OneClickShipmentRequest body (required)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string             $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\OneClickShipmentResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function oneClickShipmentWithHttpInfo(
        OneClickShipmentRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->oneClickShipmentRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-oneClickShipment');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->oneClickShipmentRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\OneClickShipmentResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\OneClickShipmentResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\OneClickShipmentResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation oneClickShipmentAsync.
     *
     * @param OneClickShipmentRequest $body
     *                                                             OneClickShipmentRequest body (required)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function oneClickShipmentAsync(
        OneClickShipmentRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->oneClickShipmentAsyncWithHttpInfo($body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation oneClickShipmentAsyncWithHttpInfo.
     *
     * @param OneClickShipmentRequest $body
     *                                                             OneClickShipmentRequest body (required)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function oneClickShipmentAsyncWithHttpInfo(
        OneClickShipmentRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\OneClickShipmentResponse';
        $request = $this->oneClickShipmentRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-oneClickShipment');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->oneClickShipmentRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'oneClickShipment'.
     *
     * @param OneClickShipmentRequest $body
     *                                                             OneClickShipmentRequest body (required)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function oneClickShipmentRequest(
        OneClickShipmentRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling oneClickShipment'
            );
        }

        $resourcePath = '/shipping/v2/oneClickShipment';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation purchaseShipment.
     *
     * @param PurchaseShipmentRequest $body
     *                                                             PurchaseShipmentRequest body (required)
     * @param null|string             $x_amzn_idempotency_key
     *                                                             A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string             $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function purchaseShipment(
        PurchaseShipmentRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PurchaseShipmentResponse {
        list($response) = $this->purchaseShipmentWithHttpInfo($body, $x_amzn_idempotency_key, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation purchaseShipmentWithHttpInfo.
     *
     * @param PurchaseShipmentRequest $body
     *                                                             PurchaseShipmentRequest body (required)
     * @param null|string             $x_amzn_idempotency_key
     *                                                             A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string             $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\PurchaseShipmentResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function purchaseShipmentWithHttpInfo(
        PurchaseShipmentRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->purchaseShipmentRequest($body, $x_amzn_idempotency_key, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-purchaseShipment');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->purchaseShipmentRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\PurchaseShipmentResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\PurchaseShipmentResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\PurchaseShipmentResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation purchaseShipmentAsync.
     *
     * @param PurchaseShipmentRequest $body
     *                                                             PurchaseShipmentRequest body (required)
     * @param null|string             $x_amzn_idempotency_key
     *                                                             A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function purchaseShipmentAsync(
        PurchaseShipmentRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->purchaseShipmentAsyncWithHttpInfo($body, $x_amzn_idempotency_key, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation purchaseShipmentAsyncWithHttpInfo.
     *
     * @param PurchaseShipmentRequest $body
     *                                                             PurchaseShipmentRequest body (required)
     * @param null|string             $x_amzn_idempotency_key
     *                                                             A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function purchaseShipmentAsyncWithHttpInfo(
        PurchaseShipmentRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\PurchaseShipmentResponse';
        $request = $this->purchaseShipmentRequest($body, $x_amzn_idempotency_key, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-purchaseShipment');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->purchaseShipmentRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'purchaseShipment'.
     *
     * @param PurchaseShipmentRequest $body
     *                                                             PurchaseShipmentRequest body (required)
     * @param null|string             $x_amzn_idempotency_key
     *                                                             A unique value which the server uses to recognize subsequent retries of the same request. (optional)
     * @param null|string             $x_amzn_shipping_business_id
     *                                                             Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function purchaseShipmentRequest(
        PurchaseShipmentRequest $body,
        ?string $x_amzn_idempotency_key = null,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling purchaseShipment'
            );
        }

        $resourcePath = '/shipping/v2/shipments';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_idempotency_key) {
            $headerParams['x-amzn-IdempotencyKey'] = ObjectSerializer::toHeaderValue($x_amzn_idempotency_key);
        }
        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation submitNdrFeedback.
     *
     * @param SubmitNdrFeedbackRequest $body
     *                                                              Request body for ndrFeedback operation (required)
     * @param null|string              $x_amzn_shipping_business_id
     *                                                              Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string              $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function submitNdrFeedback(
        SubmitNdrFeedbackRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): void {
        $this->submitNdrFeedbackWithHttpInfo($body, $x_amzn_shipping_business_id, $restrictedDataToken);
    }

    /**
     * Operation submitNdrFeedbackWithHttpInfo.
     *
     * @param SubmitNdrFeedbackRequest $body
     *                                                              Request body for ndrFeedback operation (required)
     * @param null|string              $x_amzn_shipping_business_id
     *                                                              Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string              $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of , HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function submitNdrFeedbackWithHttpInfo(
        SubmitNdrFeedbackRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->submitNdrFeedbackRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-submitNdrFeedback');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->submitNdrFeedbackRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }

            return [null, $statusCode, $response->getHeaders()];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation submitNdrFeedbackAsync.
     *
     * @param SubmitNdrFeedbackRequest $body
     *                                                              Request body for ndrFeedback operation (required)
     * @param null|string              $x_amzn_shipping_business_id
     *                                                              Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function submitNdrFeedbackAsync(
        SubmitNdrFeedbackRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->submitNdrFeedbackAsyncWithHttpInfo($body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation submitNdrFeedbackAsyncWithHttpInfo.
     *
     * @param SubmitNdrFeedbackRequest $body
     *                                                              Request body for ndrFeedback operation (required)
     * @param null|string              $x_amzn_shipping_business_id
     *                                                              Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function submitNdrFeedbackAsyncWithHttpInfo(
        SubmitNdrFeedbackRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '';
        $request = $this->submitNdrFeedbackRequest($body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-submitNdrFeedback');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->submitNdrFeedbackRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'submitNdrFeedback'.
     *
     * @param SubmitNdrFeedbackRequest $body
     *                                                              Request body for ndrFeedback operation (required)
     * @param null|string              $x_amzn_shipping_business_id
     *                                                              Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function submitNdrFeedbackRequest(
        SubmitNdrFeedbackRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling submitNdrFeedback'
            );
        }

        $resourcePath = '/shipping/v2/ndrFeedback';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'POST',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation unlinkCarrierAccount.
     *
     * @param string                      $carrier_id
     *                                                                 carrier Id to unlink with merchant. (required)
     * @param UnlinkCarrierAccountRequest $body
     *                                                                 UnlinkCarrierAccountRequest body (required)
     * @param null|string                 $x_amzn_shipping_business_id
     *                                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string                 $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function unlinkCarrierAccount(
        string $carrier_id,
        UnlinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): UnlinkCarrierAccountResponse {
        list($response) = $this->unlinkCarrierAccountWithHttpInfo($carrier_id, $body, $x_amzn_shipping_business_id, $restrictedDataToken);

        return $response;
    }

    /**
     * Operation unlinkCarrierAccountWithHttpInfo.
     *
     * @param string                      $carrier_id
     *                                                                 carrier Id to unlink with merchant. (required)
     * @param UnlinkCarrierAccountRequest $body
     *                                                                 UnlinkCarrierAccountRequest body (required)
     * @param null|string                 $x_amzn_shipping_business_id
     *                                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     * @param null|string                 $restrictedDataToken         Restricted Data Token (RDT) for accessing restricted resources (optional, required for operations that return PII)
     *
     * @return array of \SpApi\Model\shipping\v2\UnlinkCarrierAccountResponse, HTTP status code, HTTP response headers (array of strings)
     *
     * @throws ApiException              on non-2xx response
     * @throws \InvalidArgumentException
     */
    public function unlinkCarrierAccountWithHttpInfo(
        string $carrier_id,
        UnlinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): array {
        $request = $this->unlinkCarrierAccountRequest($carrier_id, $body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-unlinkCarrierAccount');
        } else {
            $request = $this->config->sign($request);
        }

        try {
            $options = $this->createHttpClientOption();

            try {
                if ($this->rateLimiterEnabled) {
                    $this->unlinkCarrierAccountRateLimiter->consume()->ensureAccepted();
                }
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getResponse()->getBody()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }
            if ('\SpApi\Model\shipping\v2\UnlinkCarrierAccountResponse' === '\SplFileObject') {
                $content = $response->getBody(); // stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ('\SpApi\Model\shipping\v2\UnlinkCarrierAccountResponse' !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializer::deserialize($content, '\SpApi\Model\shipping\v2\UnlinkCarrierAccountResponse', []),
                $response->getStatusCode(),
                $response->getHeaders(),
            ];
        } catch (ApiException $e) {
            $data = ObjectSerializer::deserialize(
                $e->getResponseBody(),
                '\SpApi\Model\shipping\v2\ErrorList',
                $e->getResponseHeaders()
            );
            $e->setResponseObject($data);

            throw $e;
        }
    }

    /**
     * Operation unlinkCarrierAccountAsync.
     *
     * @param string                      $carrier_id
     *                                                                 carrier Id to unlink with merchant. (required)
     * @param UnlinkCarrierAccountRequest $body
     *                                                                 UnlinkCarrierAccountRequest body (required)
     * @param null|string                 $x_amzn_shipping_business_id
     *                                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function unlinkCarrierAccountAsync(
        string $carrier_id,
        UnlinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): PromiseInterface {
        return $this->unlinkCarrierAccountAsyncWithHttpInfo($carrier_id, $body, $x_amzn_shipping_business_id)
            ->then(
                function ($response) {
                    return $response[0];
                }
            )
        ;
    }

    /**
     * Operation unlinkCarrierAccountAsyncWithHttpInfo.
     *
     * @param string                      $carrier_id
     *                                                                 carrier Id to unlink with merchant. (required)
     * @param UnlinkCarrierAccountRequest $body
     *                                                                 UnlinkCarrierAccountRequest body (required)
     * @param null|string                 $x_amzn_shipping_business_id
     *                                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function unlinkCarrierAccountAsyncWithHttpInfo(
        string $carrier_id,
        UnlinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null,
        ?string $restrictedDataToken = null
    ): PromiseInterface {
        $returnType = '\SpApi\Model\shipping\v2\UnlinkCarrierAccountResponse';
        $request = $this->unlinkCarrierAccountRequest($carrier_id, $body, $x_amzn_shipping_business_id);
        if (null !== $restrictedDataToken) {
            $request = RestrictedDataTokenSigner::sign($request, $restrictedDataToken, 'ShippingApi-unlinkCarrierAccount');
        } else {
            $request = $this->config->sign($request);
        }
        if ($this->rateLimiterEnabled) {
            $this->unlinkCarrierAccountRateLimiter->consume()->ensureAccepted();
        }

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ('\SplFileObject' === $returnType) {
                        $content = $response->getBody(); // stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('string' !== $returnType) {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializer::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();

                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            )
        ;
    }

    /**
     * Create request for operation 'unlinkCarrierAccount'.
     *
     * @param string                      $carrier_id
     *                                                                 carrier Id to unlink with merchant. (required)
     * @param UnlinkCarrierAccountRequest $body
     *                                                                 UnlinkCarrierAccountRequest body (required)
     * @param null|string                 $x_amzn_shipping_business_id
     *                                                                 Amazon shipping business to assume for this request. The default is AmazonShipping_UK. (optional)
     *
     * @throws \InvalidArgumentException
     */
    public function unlinkCarrierAccountRequest(
        string $carrier_id,
        UnlinkCarrierAccountRequest $body,
        ?string $x_amzn_shipping_business_id = null
    ): Request {
        // verify the required parameter 'carrier_id' is set
        if (null === $carrier_id || (is_array($carrier_id) && 0 === count($carrier_id))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $carrier_id when calling unlinkCarrierAccount'
            );
        }
        // verify the required parameter 'body' is set
        if (null === $body || (is_array($body) && 0 === count($body))) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $body when calling unlinkCarrierAccount'
            );
        }

        $resourcePath = '/shipping/v2/carrierAccounts/{carrierId}/unlink';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // header params
        if (null !== $x_amzn_shipping_business_id) {
            $headerParams['x-amzn-shipping-business-id'] = ObjectSerializer::toHeaderValue($x_amzn_shipping_business_id);
        }

        // path params
        if (null !== $carrier_id) {
            $resourcePath = str_replace(
                '{carrierId}',
                ObjectSerializer::toPathValue($carrier_id),
                $resourcePath
            );
        }

        $headers = $this->headerSelector->selectHeaders(
            ['application/json'],
            'application/json',
            $multipart
        );

        // for model (json/xml)
        if (isset($body)) {
            if ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body));
            } else {
                $httpBody = $body;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem,
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);
            } elseif ('application/json' === $headers['Content-Type']) {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams, $this->config);
            }
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializer::buildQuery($queryParams, $this->config);

        return new Request(
            'PUT',
            $this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Create http client option.
     *
     * @return array of http client options
     *
     * @throws \RuntimeException on file opening failure
     */
    protected function createHttpClientOption(): array
    {
        $options = [];
        if ($this->config->getDebug()) {
            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
            if (!$options[RequestOptions::DEBUG]) {
                throw new \RuntimeException('Failed to open the debug file: '.$this->config->getDebugFile());
            }
        }

        return $options;
    }
}
